<?php

namespace app\http\api\service;

use app\repository\dao\api\PosDao;
use DI\Attribute\Inject;
use support\Cache;

class PosService
{
    #[Inject]
    protected PosDao $posDao;

    public function getList(array &$data): array
    {
        $key = 'pos_list_' . md5(json_encode($data, 256));
        $result = Cache::get($key);
        if ($result == null) {
            $result = $this->posDao->getList($data);
            Cache::set($key, $result, 1800);
        }
        return [
            'msg'          => '获取pos列表成功',
            'code'         => 0,
            'service_name' => 'nm01',
            'data'         => $result['list'],
            'total'        => $result['total'],
        ];
    }
}